home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / weapons / Baseball Bat.lua < prev    next >
Text File  |  2010-09-29  |  3KB  |  76 lines

  1. --------------------------------------------------------------------------------
  2. -- Weapon Baseball Bat
  3. -- Original Carnage Contest Weapon
  4. -- Script by DC, August 2009, www.UnrealSoftware.de
  5. --------------------------------------------------------------------------------
  6.  
  7. -- Setup Tables
  8. if cc==nil then cc={} end
  9. cc.baseballbat={}
  10.  
  11. -- Load & Prepare Ressources
  12. cc.baseballbat.gfx_wpn=loadgfx("weapons/baseballbat.bmp")                                -- Weapon Image
  13. setmidhandle(cc.baseballbat.gfx_wpn)
  14. cc.baseballbat.sfx_attack=loadsfx("throw.ogg")                                            -- Attack Sound
  15.  
  16. --------------------------------------------------------------------------------
  17. -- Weapon: baseballbat
  18. --------------------------------------------------------------------------------
  19.  
  20. cc.baseballbat.id=addweapon("cc.baseballbat","Baseball Bat",cc.baseballbat.gfx_wpn,1)    -- Add Weapon (1 use)
  21.  
  22. function cc.baseballbat.draw()                                                            -- Draw
  23.     -- Decrease Timer (used for animation)
  24.     if weapon_timer>0.0 then
  25.         weapon_timer=weapon_timer-0.5
  26.     end
  27.     -- Draw
  28.     if getplayeraction(0)==0 then
  29.         setblend(blend_alpha)
  30.         setalpha(1)
  31.         setcolor(255,255,255)
  32.         setscale(-getplayerdirection(0),1)
  33.         setrotation(getplayerrotation(0)-(90-(weapon_timer*3))*(getplayerdirection(0)))
  34.         drawimage(cc.baseballbat.gfx_wpn,getplayerx(0)+getplayerdirection(0)*7,getplayery(0)+3)
  35.     end
  36.     -- HUD Crosshair
  37.     if weapon_shots==0 then
  38.         hudcrosshair(7,3)
  39.     end
  40. end
  41.  
  42. function cc.baseballbat.attack(attack)                                                    -- Attack
  43.     if (weapon_shots<=0) then
  44.         if (attack==1) then
  45.             -- No more weapon switching!
  46.             useweapon(0)
  47.             playsound(cc.baseballbat.sfx_attack)
  48.             weapon_shots=weapon_shots+1
  49.             -- Set timer for animation
  50.             weapon_timer=30
  51.             -- Collision
  52.             col=0
  53.             for dist=5,20,5 do
  54.                 for i=-2,2,1 do
  55.                     if col==0 then
  56.                         if collision(col5x5,getplayerx(0)+getplayerdirection(0)*7+math.sin(math.rad(getplayerrotation(0)+(i*10)))*dist,getplayery(0)+3-math.cos(math.rad(getplayerrotation(0)+(i*10)))*dist,0,1,0)==1 then
  57.                             if playercollision()~=0 and playercollision()~=playercurrent() then
  58.                                 playerpush(playercollision(),math.sin(math.rad(getplayerrotation(0)))*13,-math.cos(math.rad(getplayerrotation(0)))*13)
  59.                                 playerdamage(playercollision(),30)
  60.                                 playsound(sfx_splatter1)
  61.                                 particle(p_ring,getplayerx(playercollision()),getplayery(playercollision()))
  62.                                 particlecolor(255,0,0)
  63.                                 blood(getplayerx(playercollision()),getplayery(playercollision()))
  64.                                 col=1
  65.                                 break
  66.                             end
  67.                         end
  68.                     end
  69.                 end
  70.             end
  71.             -- End Turn
  72.             endturn()
  73.         end
  74.     end
  75. end
  76.